/*
 * Copyright (C) GSX Techedu Inc. All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 */

package com.nime.novel.crawl.runner;

import com.nime.novel.crawl.constant.CrawConstant;
import com.nime.novel.crawl.core.detail.impl.BookDetailGetServiceImpl;
import com.nime.novel.crawl.core.detail.impl.ContentDetailGetServiceImpl;
import com.nime.novel.crawl.core.list.impl.BookUrlGenServiceImpl;
import com.nime.novel.crawl.core.list.impl.ChapterUrlGenServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author liujialiang
 * @description 监控数据定时任务
 * @team wuhan operational dev.
 * @date 2020/5/7 3:51 下午
 **/
@Slf4j
@Component
public class CrawlTaskRunner {

    @Autowired
    private BookUrlGenServiceImpl bookCrawler;
    @Autowired
    private ChapterUrlGenServiceImpl chapterCrawler;
    @Autowired
    private BookDetailGetServiceImpl bookDetailGetService;
    @Autowired
    private ContentDetailGetServiceImpl contentDetailGetService;

    /**
     * 书籍列表
     */
    @Scheduled(fixedDelay = 60 * 1000)
    public void bookUrlCrawler() {
        log.info("books..........");
        bookCrawler.start(CrawConstant.POLICY);
    }
    // /**
    //  * 章节列表
    //  */
    // @Scheduled(fixedDelay = 10 * 1000)
    // public void chapterUrlCrawler() {
    //     log.info("chapters..........");
    //     chapterCrawler.start(CrawConstant.POLICY);
    // }

    //---------------------------------


    @Scheduled(fixedDelay = 10 * 1000)
    public void bookHomeParse() {
        log.info("book home..........");
        // 概况
        bookDetailGetService.start(CrawConstant.POLICY);
    }
    @Scheduled(fixedDelay = 10 * 1000)
    public void bookContentParse() {
        log.info("book index & content..........");
        // 章节正文
        contentDetailGetService.start(CrawConstant.POLICY);
    }
}
